package com.dragon.www.haier.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.dragon.www.haier.R;
import com.dragon.www.haier.view.TitleView;

import org.dragonnova.lamp.DeviceController;

/**
 * Created by liqp on 2016/10/27.
 */
public class SmartControlActivity extends Activity {

    private TitleView title;
    private LinearLayout ll_light;
    private LinearLayout ll_curtain;
    private LinearLayout ll_door;
    private LinearLayout ll_air;
    private LinearLayout ll_humidifier;
    private LinearLayout ll_music;

    private DeviceController mDeviceController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_smartcontrol);
        initView();
        mDeviceController = DeviceController.getInstance(this);
        mDeviceController.start();
        mDeviceController.discovery();

    }

    public void initView() {
        title = (TitleView) findViewById(R.id.item_title);
        ll_light = (LinearLayout) findViewById(R.id.ll_light);
        ll_curtain = (LinearLayout) findViewById(R.id.ll_curtain);
        ll_door = (LinearLayout) findViewById(R.id.ll_door);
        ll_air = (LinearLayout) findViewById(R.id.ll_air);
        ll_humidifier = (LinearLayout) findViewById(R.id.ll_humidifier);
        ll_music = (LinearLayout) findViewById(R.id.ll_music);

        title.setTextBackAction(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        ll_light.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SmartControlActivity.this, HaierLampActivity.class));
            }
        });

        ll_music.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SmartControlActivity.this, HaierTapActivity.class));
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mDeviceController.stop();
    }
}
